package com.wms.controller;

import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.entity.StockTakingTaskDetailGroup;
import com.wms.service.ReviewAdjustmentsDetailGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "skh-审核调整单详情(分组)")
@RequestMapping("/api")
public class ReviewAdjustmentsDetailGroupController {
    @Autowired
    ReviewAdjustmentsDetailGroupService reviewAdjustmentsDetailGroupService;

    @GetMapping("/queryReviewAdjustmentsDetailGroup")
    @ApiOperation(value = "查询审核调整单详情(分组)")
    public ResultBean queryReviewAdjustmentsDetailGroup(@RequestParam String code){
        StockTakingTaskDetailGroup stockTakingTaskDetailGroup = reviewAdjustmentsDetailGroupService.queryReviewAdjustmentsDetailGroup(code);
        if (stockTakingTaskDetailGroup!= null){
            return R.success("查询成功", stockTakingTaskDetailGroup);
        }
        return R.fail("查询失败");
    }

    @PutMapping("/updateTaskAuditStatusByFinishReview")
    @ApiOperation(value = "审核调整单详情(分组)审核完成")
    public ResultBean updateTaskAuditStatusByFinishReview(@RequestParam String code,@RequestParam String auditOpinion,@RequestParam int auditUserId){
        int rs = reviewAdjustmentsDetailGroupService.updateTaskAuditStatusByFinishReview(code,auditOpinion,auditUserId);
        if (rs==1){
            return R.success("审核完成");
        }
        return R.fail("审核失败");
    }

    @PostMapping("/updateTaskAuditStatusByNoFinishReview")
    @ApiOperation(value="审核调整单详情(分组)打回重盘")
    public ResultBean updateTaskAuditStatusByNoFinishReview(@RequestParam String taskCode, @RequestParam String auditOpinion,@RequestParam int userId){
        int rs = reviewAdjustmentsDetailGroupService.updateTaskAuditStatusByNoFinishReview(taskCode,auditOpinion,userId);
        if (rs>0){
            return R.success("打回重盘");
        }
        return R.fail("打回重盘失败");
    }
}
